package com.mansoor.app.islamicnames.Predicates;

import com.mansoor.app.islamicnames.beans.Name;

/**
 * Created by IntelliJ IDEA.
 * User: TKMAQ61
 * Date: Oct 15, 2009
 * Time: 2:33:35 PM
 */
public class CountPage implements org.apache.commons.collections.Predicate
{
    private final String alphabet;
    private final String gender;

    public CountPage(String alphabet, String gender)
    {
        this.alphabet = alphabet;
        this.gender = gender;

    }

   

    public boolean evaluate(Object o)
    {
        boolean result = false;
         Name name= (Name) o;

        if (gender == null)
        {
            if (name.getName().startsWith(alphabet) )
            {
                result = true;
            }
        }
        else
        {
            if (name.getName().startsWith(alphabet) && name.getGender().equalsIgnoreCase(gender))
            {
                result = true;
            }
        }

        return result;   //To change body of implemented methods use File | Settings | File Templates.
    }
}

